Skip to content

[system] Add ThemeProvider noSsr to prevent double rendering#44451

Merged
siriwatknp merged 11 commits intomui:masterfrom
siriwatknp:feat/theme-provider-force
Nov 26, 2024
Merged

[system] Add ThemeProvider noSsr to prevent double rendering#44451
siriwatknp merged 11 commits intomui:masterfrom
siriwatknp:feat/theme-provider-force

Conversation

@siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Nov 18, 2024

closes #43263

Context

The current implementation contains rerendering to make the mode initially undefined on the client to prevent any hydration mismatch.

However, for apps that does not need this double rendering behavior they could not opt-out. This PR introduces a flag to opt-out this behavior.

The use case for this flag are:


@siriwatknp siriwatknp added the scope: system The system, the design tokens / styling foundations used across components. eg. @mui/system with MUI label Nov 18, 2024
@siriwatknp siriwatknp changed the title [system] Add disableExtraRender to prevent extra rerendering [system] Add disableClientRerender to prevent extra rerendering Nov 18, 2024
@siriwatknp siriwatknp added the type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. label Nov 18, 2024
@mui-bot
Copy link

mui-bot commented Nov 18, 2024

Netlify deploy preview

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 837c1a4

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 18, 2024
@siriwatknp siriwatknp changed the title [system] Add disableClientRerender to prevent extra rerendering [system] Add noSsr to prevent double rendering Nov 25, 2024
@siriwatknp siriwatknp changed the title [system] Add noSsr to prevent double rendering [system] Add ThemeProvider noSsr to prevent double rendering Nov 25, 2024
@siriwatknp siriwatknp marked this pull request as ready for review November 25, 2024 04:25
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 25, 2024
Comment on lines +61 to +62
* If `true`, ThemeProvider will not rerender and the initial value of `mode` comes from the local storage.
* For SSR applications, you must ensure that the server render output must match the initial render output on the client.
Copy link
Member

@oliviertassinari oliviertassinari Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rewrite this prop description?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: system The system, the design tokens / styling foundations used across components. eg. @mui/system with MUI type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. v6.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Material UI 6 CssVarsProvider causes Suspense to reload async components

4 participants